﻿/* 2013/12/29 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PictureManager
{
    class TabPageSetting
    {
        private const string ValueSeparator = ",";
        private static readonly string[] ValueSeparators = new string[] { ValueSeparator };

        public TabPageSetting(string tabPageName, string tabControlName, bool isSelected)
        {
            TabControlName = tabControlName;
            TabPageName = tabPageName;
            IsSelected = isSelected;
        }

        public TabPageSetting(TabPage tabPage, TabControl tabControl)
        {
            TabPageName = tabPage.Name;
            TabControlName = tabControl.Name;
            IsSelected = tabControl.SelectedTab == tabPage;
        }

        public TabPageSetting(string setting)
        {
            string[] values = setting.Split(ValueSeparators, StringSplitOptions.RemoveEmptyEntries);
            if (values.Length == 3)
            {
                TabPageName = values[0];
                TabControlName = values[1];
                IsSelected = Boolean.Parse(values[2]);
            }
        }

        public override string ToString()
        {
            return String.Concat(TabPageName, ValueSeparator, TabControlName, ValueSeparator, IsSelected.ToString());
        }

        public bool IsSelected
        {
            get;
            set;
        }

        public string TabPageName
        {
            get;
            set;
        }

        public string TabControlName
        {
            get;
            set;
        }
    }
}
